import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Comparator;

public class Demo6708 {

  public static void main(String[] args) {
    //使用自然排序
    //Course6708[] courses=getCourses();
	List<Course6708> list=getCourses();
	Collections.sort(list,(Course6708 o1,Course6708 o2)->o1.getTerm().compareTo(o2.getTerm()));
	    for (Course6708 c : list) {
	      System.out.println(c);
	    }
  }
  private static List<Course6708> getCourses() {
    //使用数组保存一组对象
	List<Course6708> list=new ArrayList<>();
	list.add(new Course6708("A001", "C程序设计基础", "1上", 4, 80));
	list.add(new Course6708("B002", "Pthon程序基础", "1下", 2, 85));
	list.add(new Course6708("A002", "面向对象程序设计", "2上", 3, 78));
	list.add(new Course6708("C001", "Java程序高级开发", "3上", 2, 83));
	list.add(new Course6708("C002", "软件工程与UML", "3下", 3, 75));
	list.add(new Course6708("B001", "操作系统", "2下", 3, 90));
	list.add(new Course6708("A003", "数据库原理", "2上", 3, 78));
	list.add(new Course6708("B003", "网络基础", "3上", 3, 75));
	list.add(new Course6708("0001", "大学英语", "1上", 3, 80));
	list.add(new Course6708("0002", "高等数学", "1下", 2, 85));
    //Course6708[] courses=new Course6708[10];
    //courses[0]=new Course6708("A001", "C程序设计基础", "1上", 4, 80);
    //courses[1]=new Course6708("B002", "Pthon程序基础", "1下", 2, 85);
    //courses[2]=new Course6708("A002", "面向对象程序设计", "2上", 3, 78);
    //courses[3]=new Course6708("C001", "Java程序高级开发", "3上", 2, 83);
    //courses[4]=new Course6708("C002", "软件工程与UML", "3下", 3, 75);
    //courses[5]=new Course6708("B001", "操作系统", "2下", 3, 90);
    //courses[6]=new Course6708("A003", "数据库原理", "2上", 3, 78);
    //courses[7]=new Course6708("B003", "网络基础", "3上", 3, 75);
    //courses[8]=new Course6708("0001", "大学英语", "1上", 3, 80);
    //courses[9]=new Course6708("0002", "高等数学", "1下", 2, 85);
    //return courses;
	return list;
  }
}
class Course6708 implements Comparator<Course6708> {

  private String no;//课程编号
  private String name;//课程名称
  private String term;//开课学期
  private int credit;//学分
  private int score;//成绩
  
  public Course6708() {
    super();
  }

  public Course6708(String no,String name, String term, int credit, int score) {
    super();
    this.no=no;
    this.name = name;
    this.term = term;
    this.credit = credit;
    this.score = score;
  }
  public String getNo() {
    return no;
  }

  public void setNo(String no) {
    this.no = no;
  }
  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getTerm() {
    return term;
  }

  public void setTerm(String term) {
    this.term = term;
  }

  public int getCredit() {
    return credit;
  }

  public void setCredit(int credit) {
    this.credit = credit;
  }

  public int getScore() {
    return score;
  }

  public void setScore(int score) {
    this.score = score;
  }

  //@Override
  //public int compareTo(Course6708 c) {
    //支持自然排序
    //排序规则：按成绩降序
    //return c.getScore()-this.getScore();
	//return c.getTerm()-this.getTerm();
  //}
  	@Override
	public int compare(Course6708 o1, Course6708 o2) {
		// TODO Auto-generated method stub
		return o1.getTerm().compareTo(o2.getTerm());
	}
  @Override
  public String toString() {
    return "Course [no=" + no + ", name=" + name + ", term=" + term + ", credit=" + credit + ", score=" + score + "]";
  }
}

